package per.esmool;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;

public class RedisCachedSessionInterceptor implements Interceptor {

	@Override
	public void intercept(Invocation inv) {
		Controller controller = inv.getController();
		if (!(controller instanceof RedisCachedSessionController)) {
			inv.invoke();
			return;
		}
		
		RedisCachedSessionController redisCachedSessionController = (RedisCachedSessionController)controller;
		redisCachedSessionController.loadSession();
		inv.invoke();
		redisCachedSessionController.saveSession();
	}

}
 